<template>
  <div></div>
</template>

<script setup>
import { inject, onMounted, ref, onBeforeUnmount } from 'vue'
let map = ref(null)
let rqid = ref(null)
onMounted(() => {
  map.value = inject('mapScene').map
  //回到自转页面 把zoom也调整下
  map.value.setZoom(1)
  rotate()
})
function rotate() {
  let center = map.value.getCenter()
  center.lng += 0.1
  map.value.setCenter(center)
  rqid.value = requestAnimationFrame(rotate)
}
//给zoom控件绑定点击时间 关闭自转行为
let zoom = document.querySelector('.l7-control-zoom')
zoom.onclick = function () {
  cancelAnimationFrame(rqid.value)
}
onBeforeUnmount(() => {
  //离开这个页面的时候 停止自转
  cancelAnimationFrame(rqid.value)
})
</script>

<style scoped lang="scss"></style>
